import config from "../config.js"


const baseUrl = config.getBasePath();
export const myRuquest = (parmer) => {
	return new Promise(function(resolve, reject) {
		console.log("baseUrl: "+baseUrl);
		console.log("22： " + baseUrl + parmer.url);
		console.log("data： " + parmer.data);
		uni.showLoading({
			title:"获取数据中"
		})
		uni.request({
			url: baseUrl + parmer.url,
			method: parmer.method,
			data: parmer.data,
			success: (res) => {
				resolve(res);
				console.log(res);
			},
			fail: (error) => {
				uni.showToast({
					title:"获取失败"
				})
				console.log("fail failfail  ");
				reject(error);

			},
			complete() {
				uni.hideLoading();
				console.log("finish");
			}
		})
	})

}


export const postData = (parmer) => {
	parmer.method = 'POST';
	return myRuquest(parmer);
}

export const getData = (parmer) => {
	parmer.method = 'GET';
	return myRuquest(parmer);
}




